﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
 

namespace Kaiser.Extensions
{
    //public static class HttpCookieCollectionExtensions
    //{
    //    private const string AnonymousUserCookieName = "anon";

    //    public static void ClearAnonymousUser(this HttpCookieCollection cookies)
    //    {
    //        cookies.Add(new HttpCookie(AnonymousUserCookieName) { Expires = DateTime.Now.AddDays(-1) });
    //    }

    //    public static UserAnonymous GetAnonymousUser(this HttpCookieCollection cookies)
    //    {
    //        HttpCookie cookie = cookies[AnonymousUserCookieName];

    //        if (cookie != null)
    //        {
    //            try
    //            {
    //                UserCookieProxy userCookieProxy = typeof(UserCookieProxy).FromJson(cookie.Value) as UserCookieProxy;

    //                if (userCookieProxy != null)
    //                    return userCookieProxy.ToUserAnonymous();
    //            }
    //            catch { }
    //        }

    //        return new UserAnonymous();
    //    }

    //    public static void SetAnonymousUser(this HttpCookieCollection cookies, UserAnonymous user)
    //    {
    //        HttpCookie cookie = new HttpCookie(AnonymousUserCookieName, new UserCookieProxy(user).ToJson());

    //        cookie.Expires = DateTime.Now.AddDays(14);

    //        cookies.Remove(AnonymousUserCookieName);

    //        cookies.Add(cookie);
    //    }

    //    public static string GetSkinName(this HttpCookieCollection cookies)
    //    {
    //        string skin = null;
    //        HttpCookie cookie = cookies["skin"];

    //        if (cookie != null)
    //            skin = cookie.Value;

    //        return skin;
    //    }
    //}
}
